#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <raw_api.h>

#include "lwip/opt.h"

#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/tcpip.h"
#include <lwip/stats.h>
#include <lwip/snmp.h>
#include "netif/etharp.h"
#include "netif/ppp_oe.h"

#include "timer_bsp.h"




RAW_TASK_OBJ 		rsh_test_task_obj;
#define  RSH_TEST_TASK_STK_SIZE      20480
PORT_STACK rsh_test_stack[ RSH_TEST_TASK_STK_SIZE];


ip_addr_t tftp_ipaddr, tftp_netmask, tftp_gw;
struct netif tftp_netif;

extern err_t ethernetif_init(struct netif *netif);

static void
default_netif_add2(void)
{
  IP4_ADDR(&tftp_gw, 192,168,1,1);
  IP4_ADDR(&tftp_ipaddr, 192,168,1,80);
  IP4_ADDR(&tftp_netmask, 255,255,255,0);

  netif_set_default(netif_add(&tftp_netif, &tftp_ipaddr, &tftp_netmask,
                              &tftp_gw, NULL, ethernetif_init, tcpip_input));
  netif_set_up(&tftp_netif);
}

extern void rsh_interface(void);
extern void global_mem_init(unsigned int start_mem, unsigned int end_mem);
void rsh_test_task(void *arg)
{
	global_mem_init(0x30000000, 0x32000000);
	tcpip_init(0, 0);                   
	default_netif_add2();
	rsh_interface();
	
	Timer0Init();
	
	raw_task_delete(&rsh_test_task_obj);

}



void rsh_test()
{

	raw_task_create(&rsh_test_task_obj, (RAW_U8  *)"task1", 0,
	                         1, 0,  rsh_test_stack, 
	                         RSH_TEST_TASK_STK_SIZE , rsh_test_task, 1); 
}



